﻿<UserControl x:Class="Tum.PDE.ToolFramework.Modeling.Visualization.Controls.ModelTreeControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"  
             d:DesignHeight="300" d:DesignWidth="300" TextOptions.TextFormattingMode="Display"
             
             xmlns:tree="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.ModelTree"             
             xmlns:vm="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.Menu"
             xmlns:vma="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.Attached"
             xmlns:dd="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.Attached.DragDrop"
             
             xmlns:beh="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Behaviors"
             xmlns:inter="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             
             vma:ViewModelAttachedCommands.Loaded="{Binding LoadedCommand}"
             vma:ViewModelAttachedCommands.Unloaded="{Binding UnloadedCommand}">
    
    <UserControl.Resources>
        <ResourceDictionary>
            <!-- DragDrop adorner data template-->
            <DataTemplate x:Key="ModelTreeAdornerTemplate">
                <TextBlock Text="{Binding Path=DomainElementFullName, Mode=OneWay}" Margin="15,0,0,0"/>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    
    <Grid>
        <tree:ModelTreeView x:Name="TreeviewMain" ScrollViewer.IsDeferredScrollingEnabled="True"
                  ItemsSource="{Binding Path=RootViewModels, Mode=OneWay}" Focusable="True"
                  dd:DragDrop.IsDragSource="True" dd:DragDrop.DragAdornerTemplate="{StaticResource ModelTreeAdornerTemplate}">

            <inter:Interaction.Behaviors>
                <beh:TreeViewClickedAndSelectedItemBehavior ClickedItem="{Binding Mode=TwoWay, Path=ClickedItemViewModel}" SelectedItem="{Binding Mode=TwoWay, Path=SelectedItemViewModel}"/>
                <beh:FrameworkElementContextMenuBehavior/>
             </inter:Interaction.Behaviors>

            <tree:ModelTreeView.ContextMenu>
                <ContextMenu x:Name="TreeviewMainContextMenu" ItemContainerStyleSelector="{StaticResource ContextMenuItemStyleSelector}" ItemsSource="{Binding Path=ContextMenu.Children, Mode=OneWay}"/>
            </tree:ModelTreeView.ContextMenu>
        </tree:ModelTreeView>
    </Grid>
</UserControl>
